﻿/* 
 * Shuriken is the legal property of its developers. Please refer to the
 * COPYRIGHT file distributed with this
 * source distribution.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

using System;
using System.Collections.Generic;
using Shuriken.Base;

namespace Shuriken.Modules
{
    public class ShurikenApplicationItem : IApplicationItem
    {
        #region IApplicationSubject Members

        public bool IsRunning
        {
            get
            {
                return true;
            }
        }

        #endregion

        #region ISubject Members

        public List<IAction> GetListOfActions()
        {
            List<IAction> actions = new List<IAction>();

            //actions.Add(new ShurikenApplicationAboutAction());
            //actions.Add(new ShurikenApplicationSettingAction());
            //actions.Add(new ShurikenApplicationExitAction());

            return actions;
        }

        #endregion

        #region IObject Members

        public string Name
        {
            get { return "Shuriken"; }
        }

        public string Description
        {
            get { return "Shuriken Launcher Application"; }
        }

        public string Icon
        {
            get
            {
                return "shuriken_application_icon";
            }
            set
            {
            }
        }

        #endregion

        [ActionName("About")]
        [ActionSubjectType(typeof(ShurikenApplicationItem))]
        public class ShurikenApplicationAboutAction : BaseAction
        {
            public override void Execute(ISubject subject)
            {
                ApplicationServiceHost.DefaultInstance.ExecuteCommand("Application", "About");
            }

            public override bool CanExecuteOn(ISubject subject)
            {
                if (subject.GetType().Equals(typeof(ShurikenApplicationItem)))
                {
                    return true;
                }

                return false; 
            }
        }

        [DefaultAction]
        [ActionName("Settings")]
        [ActionSubjectType(typeof(ShurikenApplicationItem))]
        public class ShurikenApplicationSettingAction : BaseAction
        {
            public override void Execute(ISubject subject)
            {
                ApplicationServiceHost.DefaultInstance.ExecuteCommand("Application", "Settings");
            }

            public override bool CanExecuteOn(ISubject subject)
            {
                if (subject.GetType().Equals(typeof(ShurikenApplicationItem)))
                {
                    return true;
                }

                return false; 
            }
        }

        [ActionName("Exit")]
        [ActionSubjectType(typeof(ShurikenApplicationItem))]
        public class ShurikenApplicationExitAction : BaseAction
        {
            public override void Execute(ISubject subject)
            {
                ApplicationServiceHost.DefaultInstance.ExecuteCommand("Application", "Exit");
            }

            public override bool CanExecuteOn(ISubject subject)
            {
                if (subject.GetType().Equals(typeof(ShurikenApplicationItem)))
                {
                    return true;
                }

                return false; 
            }
        }

        [ActionName("Reveal")]
        [ActionSubjectType(typeof(ShurikenApplicationItem))]
        public class ShurikenApplicationRevealAction : BaseAction
        {
            public override void Execute(ISubject subject)
            {
                ApplicationServiceHost.DefaultInstance.ExecuteCommand("Application", "RevealExecutable");
            }

            public override bool CanExecuteOn(ISubject subject)
            {
                if (subject.GetType().Equals(typeof(ShurikenApplicationItem)))
                {
                    return true;
                }

                return false;
            }
        }

        [ActionName("Open Log File")]
        [ActionSubjectType(typeof(ShurikenApplicationItem))]
        public class ShurikenApplicationOpenLogFileAction : BaseAction
        {
            public override void Execute(ISubject subject)
            {
                ApplicationServiceHost.DefaultInstance.ExecuteCommand("Application", "OpenLogFile");
            }

            public override bool CanExecuteOn(ISubject subject)
            {
                if (subject.GetType().Equals(typeof(ShurikenApplicationItem)))
                {
                    return true;
                }

                return false;
            }
        }
    }

}
